package com.cn.wanxi.servlet.user;

import com.cn.wanxi.model.UserModel;
import com.cn.wanxi.service.IUserService;
import com.cn.wanxi.service.impl.UserServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/userSelect")
public class UserSelectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        IUserService iUserService = new UserServiceImpl();
        List<UserModel> list = iUserService.findAll();

        JSONArray jsonArray = JSONArray.fromObject(list);
        resp.getWriter().println(jsonArray);
//        req.setAttribute("list",list);
//        req.getRequestDispatcher("/back/userSelect.jsp").forward(req,resp);
    }
}
